<template lang="pug">
    div#appointment
        select-group
        time-panel
        yd-button(size='large',bgcolor='#000',color='#FFF',shape='circle',@click.native="confirm") 确认预约

</template>
<script>
import SelectGroup from "../../components/SelectGroup.vue";
import TimePanel from "../../components/TimePanel.vue";
import { mapState } from "vuex";

export default {
  components: {
    SelectGroup,
    TimePanel
  },
  computed: {
    ...mapState(["item", "staff", "time"])
  },
  methods: {
    confirm() {
      this.$api.v1
        .order_confirmOrder_post({
          data: {
            sid: window.data.sid,
            uid: window.data.uid,
            uname: window.data.name,
            time: this.item.time,
            staffid: this.staff.bid,
            staffname: this.staff.bname,
            starttime: this.time.unix(),
            tid: this.item.tid,
            tname: this.item.tname
          }
        })
        .then(resp => {
          if (resp.data.result) {
            const oid = resp.data.oid;
            this.$router.push({
              path: "/appointment/info",
              query: { oid: oid }
            });
          } else {
            alert(resp.data.message);
          }
        });
    }
  }
};
</script>
<style lang="stylus" scoped>
.yd-btn-block {
  width: 75%;
  margin: 1rem auto;
}
</style>


